home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWbostream.z / RWbostream
Encoding:
Text File  |  1998-10-30  |  16.9 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWbostream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/bstream.h>
  13.  
  14.  
  15.  
  16.               // Construct an RWbostream, using cout's streambuf:
  17.           RWbostream bstr(cout);
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm specializes the abstract base class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm to store
  24.      variables in binary format.  The results can be restored by using its
  25.      counterpart RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm.  You can think of it as a binary veneer over an
  26.      associated ssssttttrrrreeeeaaaammmmbbbbuuuuffff.  Because the RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm retains no information
  27.      about the state of its associated ssssttttrrrreeeeaaaammmmbbbbuuuuffff, its use can be freely
  28.      exchanged with other users of the ssssttttrrrreeeeaaaammmmbbbbuuuuffff (such as oooossssttttrrrreeeeaaaammmm or
  29.      ooooffffssssttttrrrreeeeaaaammmm).  NNNNooootttteeee tttthhhhaaaatttt vvvvaaaarrrriiiiaaaabbbblllleeeessss sssshhhhoooouuuulllldddd nnnnooootttt bbbbeeee sssseeeeppppaaaarrrraaaatttteeeedddd wwwwiiiitttthhhh wwwwhhhhiiiitttteeee ssssppppaaaacccceeee.
  30.      Such white space would be interpreted literally and would have to be read
  31.      back in as a character string.  RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm can be interrogated as to the
  32.      stream state using member functions ggggoooooooodddd(((()))), bbbbaaaadddd(((()))), eeeeooooffff(((()))), eeeettttcccc.
  33.  
  34. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  35.      None
  36.  
  37. EEEExxxxaaaammmmpppplllleeee
  38.      See RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm for an example of how the file "ddddaaaattttaaaa....ddddaaaatttt" might be read
  39.      back in.
  40.  
  41.               #include <rw/bstream.h>
  42.           #include <fstream.h>
  43.           main(){
  44.             ofstream fstr("data.dat");   // Open an output file
  45.             RWbostream bstr(fstr);       // Construct an RWbostream from it
  46.             int i = 5;
  47.             float f = 22.1;
  48.             double d = -0.05;
  49.             bstr << i;             // Store an int in binary
  50.             bstr << f << d;        // Store a float & double
  51.           }
  52.  
  53.  
  54. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  55.               RWbostream(streambuf* s);
  56.  
  57.  
  58.      Construct an RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff ssss.  For DOS, the ssssttttrrrreeeeaaaammmmbbbbuuuuffff
  59.      must have been opened in binary mode.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               RWbostream(ostream& str);
  75.  
  76.  
  77.      Construct an RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff associated with the output
  78.      stream ssssttttrrrr.  For DOS, the ssssttttrrrreeeeaaaammmmbbbbuuuuffff must have been opened in binary mode.
  79.      This can be done by specifying iiiioooossss::::::::bbbbiiiinnnnaaaarrrryyyy as part of the second argument
  80.      to the constructor for an ooooffffssssttttrrrreeeeaaaammmm.  Using the example above, the line to
  81.      create the ooooffffssssttttrrrreeeeaaaammmm would read, ooooffffssssttttrrrreeeeaaaammmm ffffssssttttrrrr((((""""ddddaaaattttaaaa....ddddaaaatttt"""",,,, iiiioooossss::::::::oooouuuutttt ||||
  82.      iiiioooossss::::::::bbbbiiiinnnnaaaarrrryyyy))));;;; where the "||||" is the binary OOOORRRR operator.
  83.  
  84. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  85.               virtual ~RWvostream();
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.      This virtual destructor allows specializing classes to deallocate any
  93.      resources that they may have allocated.
  94.  
  95. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  96.               virtual RWvostream&
  97.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s);
  98.  
  99.  
  100.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the character string starting at
  101.      ssss to the output stream in binary.  The character string is expected to be
  102.      null terminated.
  103.  
  104.               virtual RWvostream&
  105.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const wchar_t* ws);
  106.  
  107.  
  108.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wide character string
  109.      starting at wwwwssss to the output stream in binary.  The wide character string
  110.      is expected to be null terminated.
  111.  
  112.               virtual RWvostream&
  113.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c);
  114.  
  115.  
  116.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the cccchhhhaaaarrrr cccc to the output stream
  117.      in binary.
  118.  
  119.               virtual RWvostream&
  120.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc);
  121.  
  122.  
  123.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wide cccchhhhaaaarrrr wwwwcccc to the output
  124.      stream in binary.
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual RWvostream&
  141.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c);
  142.  
  143.  
  144.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output
  145.      stream in binary.
  146.  
  147.               virtual RWvostream&
  148.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d);
  149.  
  150.  
  151.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the ddddoooouuuubbbblllleeee dddd to the output stream
  152.      in binary.
  153.  
  154.               virtual RWvostream&
  155.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f);
  156.  
  157.  
  158.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the ffffllllooooaaaatttt ffff to the output stream
  159.      in binary.
  160.  
  161.               virtual RWvostream&
  162.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i);
  163.  
  164.  
  165.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the iiiinnnntttt iiii to the output stream in
  166.      binary.
  167.  
  168.               virtual RWvostream&
  169.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i);
  170.  
  171.  
  172.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt iiii to the output
  173.      stream in binary.
  174.  
  175.               virtual RWvostream&
  176.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l);
  177.  
  178.  
  179.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the lllloooonnnngggg llll to the output stream
  180.      in binary.
  181.  
  182.               virtual RWvostream&
  183.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l);
  184.  
  185.  
  186.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg llll to the output
  187.      stream in binary.
  188.  
  189.               virtual RWvostream&
  190.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s);
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the sssshhhhoooorrrrtttt ssss to the output stream
  207.      in binary.
  208.  
  209.               virtual RWvostream&
  210.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned short s);
  211.  
  212.  
  213.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt ssss to the
  214.      output stream in binary.
  215.  
  216.  
  217.           ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  218.  
  219.  
  220.      Inherited via RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm from RRRRWWWWvvvviiiioooossss....
  221.  
  222. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  223.               virtual RWvostream&
  224.           fffflllluuuusssshhhh();
  225.  
  226.  
  227.      Send the contents of the stream buffer to output immediately.
  228.  
  229.               virtual RWvostream&
  230.           ppppuuuutttt(char c);
  231.  
  232.  
  233.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the cccchhhhaaaarrrr cccc to the output stream.
  234.  
  235.               virtual RWvostream&
  236.           ppppuuuutttt(wchar_t wc);
  237.  
  238.  
  239.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wide character wwwwcccc to the
  240.      output stream.
  241.  
  242.               virtual RWvostream&
  243.           ppppuuuutttt(unsigned char c);
  244.  
  245.  
  246.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output
  247.      stream.
  248.  
  249.               virtual RWvostream&
  250.           ppppuuuutttt(const char* p, size_t N);
  251.  
  252.  
  253.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of cccchhhhaaaarrrrs starting at pppp
  254.      to the output stream in binary.
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               virtual RWvostream&
  273.           ppppuuuutttt(const wchar_t* p, size_t N);
  274.  
  275.  
  276.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of wide cccchhhhaaaarrrrs starting
  277.      at pppp to the output stream in binary.
  278.  
  279.               virtual RWvostream&
  280.           ppppuuuutttt(const unsigned char* p, size_t N);
  281.  
  282.  
  283.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs
  284.      starting at pppp to the output stream in binary.
  285.  
  286.               virtual RWvostream&
  287.           ppppuuuutttt(const short* p, size_t N);
  288.  
  289.  
  290.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of sssshhhhoooorrrrtttts starting at
  291.      pppp to the output stream in binary.
  292.  
  293.               virtual RWvostream&
  294.           ppppuuuutttt(const unsigned short* p, size_t N);
  295.  
  296.  
  297.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts
  298.      starting at pppp to the output stream in binary.
  299.  
  300.               virtual RWvostream&
  301.           ppppuuuutttt(const int* p, size_t N);
  302.  
  303.  
  304.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of iiiinnnntttts starting at pppp
  305.      to the output stream in binary.
  306.  
  307.               virtual RWvostream&
  308.           ppppuuuutttt(const unsigned int* p, size_t N);
  309.  
  310.  
  311.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts
  312.      starting at pppp to the output stream in binary.
  313.  
  314.               virtual RWvostream&
  315.           ppppuuuutttt(const long* p, size_t N);
  316.  
  317.  
  318.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of lllloooonnnnggggs starting at pppp
  319.      to the output stream in binary.
  320.  
  321.               virtual RWvostream&
  322.           ppppuuuutttt(const unsigned long* p, size_t N);
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs
  339.      starting at pppp to the output stream in binary.
  340.  
  341.               virtual RWvostream&
  342.           ppppuuuutttt(const float* p, size_t N);
  343.  
  344.  
  345.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of ffffllllooooaaaatttts starting at
  346.      pppp to the output stream in binary.
  347.  
  348.               virtual RWvostream&
  349.           ppppuuuutttt(const double* p, size_t N);
  350.  
  351.  
  352.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of ddddoooouuuubbbblllleeees starting at
  353.      pppp to the output stream in binary.
  354.  
  355.               virtual RWvostream&
  356.           ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char* p, size_t N);
  357.  
  358.  
  359.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Data is formatted as a string
  360.      containing NNNN characters.
  361.  
  362.               virtual RWvostream&
  363.           ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N);
  364.  
  365.  
  366.      Store the character string, iiiinnnncccclllluuuuddddiiiinnnngggg eeeemmmmbbbbeeeeddddddddeeeedddd nnnnuuuullllllllssss, starting at s to
  367.      the output string.
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.